//
//  ProductRightNaviView.m
//  ChunLaiZhuangClient
//
//  Created by xielihui on 16/3/24.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "ProductRightNaviView.h"

@interface ProductRightNaviView()
@property (weak, nonatomic) IBOutlet UILabel *shopCartNumLabel;

@end

@implementation ProductRightNaviView

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"ProductRightNaviView" owner:self options:nil];
        UIView *view = array[0];
        [self addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.leading.trailing.equalTo(@(0));
        }];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)updateShopCartNumber:(NSInteger)number {
    if (number <= 0) {
        self.productNum.hidden = YES;
    } else {
        self.productNum.hidden = NO;
    }
    self.productNum.text = [NSString stringWithFormat:@"%ld", number];
}

- (void)updateFavoriteInfo:(BOOL)isWish {
    if (isWish) {
        [self.favoBtn setImage:[UIImage imageNamed:@"nav_unatt"] forState:UIControlStateNormal];
    } else {
        [self.favoBtn setImage:[UIImage imageNamed:@"nav_att"] forState:UIControlStateNormal];
    }
}

- (IBAction)addToShopBagAction:(id)sender {
    if (self.addToShopBagBlock) {
        self.addToShopBagBlock();
    }
}

- (IBAction)addAttentionAction:(id)sender {
    if (self.addAttentionBlock) {
        self.addAttentionBlock();
    }
}

- (IBAction)shareAction:(id)sender {
    if (self.shareBlock) {
        self.shareBlock();
    }
}

@end
